package com.young.rpc.http;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.gson.Gson;

import java.util.HashMap;
import java.util.Map;

/**
 * 心跳请求体
 */
public class HeartBeatRequestBody implements RequestBody {

    private static final Gson GSON = new Gson();

    @JsonIgnore
    private String url;

    private String project;

    private String profile;

    private String cloud;

    private String group;

    private String host;

    private String ip;

    private Integer port;

    /** 所有jobkey,jobkey之间以逗号分隔 */
    private String jobs;

    private Integer communicationType;

    public Integer getCommunicationType() {
        return communicationType;
    }

    public void setCommunicationType(Integer communicationType) {
        this.communicationType = communicationType;
    }

    public String getProfile() {
        return profile;
    }

    public void setProfile(String profile) {
        this.profile = profile;
    }

    public String getCloud() {
        return cloud;
    }

    public void setCloud(String cloud) {
        this.cloud = cloud;
    }

    public String getGroup() {
        return group;
    }

    public void setGroup(String group) {
        this.group = group;
    }

    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public Integer getPort() {
        return port;
    }

    public void setPort(Integer port) {
        this.port = port;
    }

    @Override
    public String getUrl() {
        return url;
    }

    @Override
    public String getBody() {
        return GSON.toJson(this,this.getClass());
    }

    @Override
    public Map<String, Object> getParameter() {
        Map<String,Object> parameter = new HashMap<>(16);
        parameter.put("project",project);
        parameter.put("profile",profile);
        parameter.put("cloud",cloud);
        parameter.put("group",group);
        parameter.put("host",host);
        parameter.put("ip",ip);
        parameter.put("port",port);
        parameter.put("communicationType",communicationType);
        parameter.put("jobs",jobs);
        return parameter;
    }

    public void setProject(String project) {
        this.project = project;
    }

    public String getProject() {
        return project;
    }

    public void setJobs(String jobs) {
        this.jobs = jobs;
    }

    public String getJobs() {
        return jobs;
    }
}
